From 76afea6ca75424317918d38c3de2d70eedba3a20 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 5 Apr 2004 14:13:23 +0000 Subject: [PATCH] From Rick Richardson. Sets icon_descr Sets creation_time Adds option to remove retired caches. --- gpsbabel/navicache.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/gpsbabel/navicache.c b/gpsbabel/navicache.c index e42bbb6e9..1b9c6173a 100644 --- a/gpsbabel/navicache.c +++ b/gpsbabel/navicache.c @@ -27,6 +27,15 @@ static waypoint *wpt_tmp; FILE *fd; FILE *ofd; +static char *noretired; + +static +arglist_t nav_args[] = { + {"noretired", &noretired, "Suppress retired geocaches.", + ARGTYPE_BOOL }, + {0, 0, 0, 0} +}; + #define MYNAME "navicache" #define MY_CBUF 4096 @@ -133,7 +142,40 @@ nav_start(void *data, const char *el, const char **attr) wpt_tmp->gc_data.terr = x * 10; } else if (0 == strcmp(ap[0], "cache_type")) { + static char buf[512]; + wpt_tmp->gc_data.type = nc_mktype(ap[1]); + if (!strcmp(ap[1], "normal")) + wpt_tmp->icon_descr = "Geocache-regular"; + else if (!strcmp(ap[1], "multi-part")) + wpt_tmp->icon_descr = "Geocache-multi"; + else if (!strcmp(ap[1], "moving_travelling")) + wpt_tmp->icon_descr = "Geocache-moving"; + else { + sprintf(buf, "Geocache-%-.20s", ap[1]); + wpt_tmp->icon_descr = xstrdup(buf); + } + } else + if (0 == strcmp(ap[0], "hidden_date")) { + struct tm tm; + + sscanf(ap[1], "%d-%d-%d", + &tm.tm_year, + &tm.tm_mon, + &tm.tm_mday); + tm.tm_mon -= 1; + tm.tm_year -= 1900; + tm.tm_isdst = 0; + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + wpt_tmp->creation_time = mktime(&tm); + } else + if (0 == strcmp(ap[0], "retired")) { + if (!strcmp(ap[1], "yes") && noretired) { + xfree(wpt_tmp); + return; + } } else if (0 == strcmp(ap[0], "cache_size")) { wpt_tmp->gc_data.container = nc_mkcont(ap[1]); @@ -212,5 +254,5 @@ ff_vecs_t navicache_vecs = { nav_wr_deinit, nav_read, nav_write, - NULL + nav_args, }; -- 2.30.2